package RuiGe;

import java.util.Scanner;

public class Demo2 {
    public static void main(String[] args) {
        Scanner s=new Scanner(System.in);
        int n=s.nextInt();
        String[] str=new String[n];
        for(int i=0;i<n;i++){
            str[i]=s.next();
        }
        Integer[] arr=new Integer[n];
        Integer max=0;
        for(int j=0;j<n;j++){
            max=0;
            String[] strTmp=str[j].split(",");
            for(int k=0;k<strTmp.length;k++){
                Integer tmp=Integer.valueOf(strTmp[k]);
                if(tmp>max){
                    max=tmp;
                }
            }
            arr[j]=max;
        }
        max=0;
        for(int i=0;i<n;i++){
            max=max>arr[i]?max:arr[i];
        }
        Integer[] arr2=new Integer[n];
        int sum=0;
        for(int k=0;k<n;k++){
            if(arr[k]==max){
                arr2[sum++]=k;
            }
        }
        for(int i=0;i<sum;i++){
            if(i==sum-1){
                System.out.printf("%d",arr2[i]+1);
            }
            else{
                System.out.printf("%d,",arr2[i]+1);
            }
        }


    }
}
